﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;

namespace GUILibrary
{
    class DisplayOnActionComponent : Component, ActionListener
    {
        /// <summary>
        /// Name of image to display
        /// </summary>
        public string TextureName
        {
            get;
            set;
        }

        /// <summary>
        /// The Action to listen for
        /// </summary>
        public string ActionToListen
        {
            get;
            set;
        }

        private Texture2D image;
        private bool hasTheAction;

        public override void Draw(Microsoft.Xna.Framework.Graphics.SpriteBatch batch)
        {
            if (hasTheAction)
                batch.Draw(image, ScreenPosition, Color.White);
        }

        public override void Load(Microsoft.Xna.Framework.Content.ContentManager cm)
        {
            image = cm.Load<Texture2D>(TextureName);
        }


        public void UpdateAction(List<string> currentActions)
        {
            if (currentActions.Contains(ActionToListen))
                hasTheAction = true;
            else
                hasTheAction = false;
        }
    }
}
